﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace _2008A.PH5._0221_0317.FuXi.EFCore.Migrations
{
    public partial class addtablecategoryandbrand : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<string>(
                name: "ImagePath",
                table: "tb_product_image",
                type: "nvarchar(max)",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<Guid>(
                name: "ProductEntityId",
                table: "tb_product_image",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "ProductId",
                table: "tb_product_image",
                type: "uniqueidentifier",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AddColumn<Guid>(
                name: "BrandId",
                table: "tb_product",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "CategoryId",
                table: "tb_product",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "CoverImage",
                table: "tb_product",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Flag",
                table: "tb_product",
                type: "nvarchar(max)",
                nullable: true,defaultValue:"000000");

            migrationBuilder.AddColumn<string>(
                name: "IsUp",
                table: "tb_product",
                type: "nvarchar(max)",
                nullable: true,defaultValue:"1");

            migrationBuilder.AddColumn<decimal>(
                name: "Price",
                table: "tb_product",
                type: "decimal(18,2)",
                nullable: false,
                defaultValue: 0m);

            migrationBuilder.AddColumn<int>(
                name: "SaleNumber",
                table: "tb_product",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "Spec",
                table: "tb_product",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "Stock",
                table: "tb_product",
                type: "int",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<Guid>(
                name: "StoreId",
                table: "tb_product",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "StoreName",
                table: "tb_product",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Title",
                table: "tb_product",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "LoginName",
                table: "tb_member",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Password",
                table: "tb_member",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Statue",
                table: "tb_member",
                type: "nvarchar(max)",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "tb_brand",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false,defaultValueSql:"newid()"),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Logo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "datetime2", nullable: false,defaultValueSql:"getdate()"),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    UpdatedTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_tb_brand", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "tb_category",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "newid()"),
                    PId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Icon = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "getdate()"),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    UpdatedTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_tb_category", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "tb_log",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "newid()"),
                    MemberId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    IP = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Port = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    ApiUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Content = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CreatedTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "getdate()"),
                    CreatedBy = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    UpdatedTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(max)", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_tb_log", x => x.Id);
                });

            migrationBuilder.CreateIndex(
                name: "IX_tb_product_image_ProductEntityId",
                table: "tb_product_image",
                column: "ProductEntityId");

            migrationBuilder.AddForeignKey(
                name: "FK_tb_product_image_tb_product_ProductEntityId",
                table: "tb_product_image",
                column: "ProductEntityId",
                principalTable: "tb_product",
                principalColumn: "Id");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_tb_product_image_tb_product_ProductEntityId",
                table: "tb_product_image");

            migrationBuilder.DropTable(
                name: "tb_brand");

            migrationBuilder.DropTable(
                name: "tb_category");

            migrationBuilder.DropTable(
                name: "tb_log");

            migrationBuilder.DropIndex(
                name: "IX_tb_product_image_ProductEntityId",
                table: "tb_product_image");

            migrationBuilder.DropColumn(
                name: "ImagePath",
                table: "tb_product_image");

            migrationBuilder.DropColumn(
                name: "ProductEntityId",
                table: "tb_product_image");

            migrationBuilder.DropColumn(
                name: "ProductId",
                table: "tb_product_image");

            migrationBuilder.DropColumn(
                name: "BrandId",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "CategoryId",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "CoverImage",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "Flag",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "IsUp",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "Price",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "SaleNumber",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "Spec",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "Stock",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "StoreId",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "StoreName",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "Title",
                table: "tb_product");

            migrationBuilder.DropColumn(
                name: "LoginName",
                table: "tb_member");

            migrationBuilder.DropColumn(
                name: "Password",
                table: "tb_member");

            migrationBuilder.DropColumn(
                name: "Statue",
                table: "tb_member");
        }
    }
}
